
CC=gcc
CXX=g++

debug_flag = -DUNIT_TEST -Wall -DBOOST_ALL_NO_LIB -std=c++0x
BOOST_HOME = /home/astrol/sdk/boost_1_54_0
BOOST_LIB = $(BOOST_HOME)/stage/lib
libraries = -L$(BOOST_HOME)/stage/lib -lboost_system -lboost_thread -lboost_date_time -lpthread -lrt
includes = -I$(BOOST_HOME) -Ideps/include -Isrc/network -Isrc/logic

#VPATH = ./src/network 
vpath %.cpp src/network src/logic

objects = TcpNet.o TcpServer.o CommonListener.o

all: main

$(objects) : $(objects:.o=.cpp)
	$(CXX)  $(debug_flag) $(includes) -c $^

TcpServer.o: src/network/TcpServer.cpp
	$(CXX)  $(debug_flag) $(includes) -c src/network/TcpServer.cpp

TcpNet.o: src/network/TcpNet.cpp
	$(CXX)  $(debug_flag) -DCLIENT_TEST $(includes) -c src/network/TcpNet.cpp

CommonListener.o: src/logic/CommonListener.cpp
	$(CXX)  $(debug_flag) -DCOMMONLISTENER_TEST $(includes) -c src/logic/CommonListener.cpp

lib:$(objects)
	$(AR) crf lib/nativelib.a $(objects)

main:lib
	$(CXX) lib/nativelib.a -o main $(libraries) 

client: TcpNet.o
	$(CXX) TcpNet.o -o client $(libraries) $(debug_flag) -DCLIENT_TEST

server: TcpServer.o
	$(CXX) TcpServer.o -o server $(libraries) $(debug_flag) -DSERVER_TEST

listener: CommonListener.o TcpServer.o
	$(CXX) CommonListener.o TcpServer.o -o listener $(libraries) $(debug_flag) -DCOMMONLISTENER_TEST

.PHONY:clean

clean:
	rm *.o lib/*.a main server client listener




